package com.hsd.znsh.repository;

import com.hsd.znsh.entity.Property;
import com.hsd.znsh.entity.SensorTypeProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface SensorTypePropertyRepository extends JpaRepository<SensorTypeProperty,Integer> {

    @Query("select propertyId from SensorTypeProperty where sensorTypeId = ?1")
    List<Integer> findPropertyIdListBySensorTypeId(Integer sensorTypeId);

    void deleteBySensorTypeId(Integer sensorTypeId);

    void deleteByPropertyId(Integer propertyId);

    SensorTypeProperty findBySensorTypeIdAndBh(Integer sensorTypeId,Integer bh);

    @Query("select max(bh) from SensorTypeProperty where sensorTypeId=?1")
    Integer findMaxBhBySensorTypeId(Integer sensorTypeId);
}
